<?php
session_start();
$user=$_SESSION['user'];

if (!empty($user)){
	
	$conexion=mysql_connect("localhost", "root", "") or die ("Error al Conectar!");
	mysql_select_db("hazarte") or die ("Verifique la Base de Datos");
	
	$sql = "SELECT COUNT(*) FROM  `usuarios` WHERE  `usuario` =  '$user'";
	$resultado = mysql_query($sql);
	$msg = mysql_fetch_row($resultado);
	
	if  ($msg[0] == 1){

		$sql = "SELECT nombre,id FROM  `imagenes`";
		$resulset = mysql_query($sql);
		$rowsNom = array();
		$rowsId = array();
		while ($row = mysql_fetch_array($resulset)) {
			$rowsNom[] = $row['nombre'];
			$rowsId[] = $row['id'];
		}
		$numRows= count($rowsNom);
		?>
		<!doctype html>
		<html  lang =  "es">
			<head>
				<meta charset="utf-8">
				<meta name="autor" content="jaimelopez">
				<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
				
				<link href="../libs/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css">
				<link href="../css/estilo.css" rel="stylesheet" type="text/css">
		
				<script src="../libs/jquery/jquery_1.11.js" type="text/javascript"></script> 
				<script src="../libs/bootstrap/js/bootstrap.js" type="text/javascript"></script>
				<script src="../js/funcionalidad.js" type="text/javascript"></script> 
			    
			</head>
				
			<body id="bodyClass">
		
				<div class="col-md-8 col-md-offset-2">
					<div class="page-header" style="text-align:center;">
						<h2>Administraci&oacute;n Haz Arte</h2>
					</div>
					<form action="delete.php" id="form1" method="post">
					
					  <div class="input-group">
						  <span class="input-group-addon">Seleccione el nombre de la foto que desea eliminar</span>
						  <select class="form-control" name="nombre" id="nombre">
								
								<?php for ($i = 0; $i < $numRows; $i++) { 	
								echo "<option value='".$rowsId[$i]."' > ".$rowsNom[$i]." </option>";
								}?>
						
						  </select>
					   </div><br>
					 
					  <div class="modal-footer" style="text-align:center;">
						        <button type="submit" id="eliminar" class="btn btn-primary btn-lg" style="float:left">Eliminar</button>
						         <a href="administrar.php" class="btn btn-primary btn-lg" style="float:right">Volver</a>
							</div>
					</form>
				</div>
			</body>
		</html>	
	
<?php 
	}else{
		//header('Location: error.html');
		echo "usuario no existe";

	}
}else{
	//header('Location: error.html');
		echo "no hay usuariio";
}

?>


